home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / c / rel_mac2.c < prev    next >
C/C++ Source or Header  |  1992-03-01  |  3KB  |  86 lines

  1.  
  2. /* Copyright William Schelter. All rights reserved.  This file does
  3. the low level relocation which tends to be very system dependent.
  4. It is included by the file sfasl.c
  5. */
  6.  
  7.  
  8. relocate()
  9. {
  10.   char *where;
  11.   describe_sym(relocation_info.r_symndx);
  12.   where = the_start + relocation_info.r_vaddr;
  13.   dprintf (where has %x , *where);
  14.   dprintf(   at %x -->, where );
  15.   
  16.   if (relocation_info.r_type == R_ABS)
  17.     { dprintf( r_abs ,0)  return; }
  18.   switch(relocation_info.r_type)
  19.     { int *q;
  20.  
  21.     case      R_RELLONG:
  22.       dprintf(new val r_rellong %x ,  *((int *)where) + 
  23.           symbol_table[relocation_info.r_symndx].n_value);
  24.       *(int *)where= *((int *)where) +
  25.                  symbol_table[relocation_info.r_symndx].n_value;
  26.       break;
  27.  
  28.     case    R_RELWORD:
  29.         dprintf(new val r_relword %x ,  *((short *)where) + 
  30.           symbol_table[relocation_info.r_symndx].n_value);
  31.       *(short *)where= *((short *)where) +
  32.                  symbol_table[relocation_info.r_symndx].n_value;
  33.       break;
  34.     case R_PCRLONG:
  35.  
  36.       dprintf( r_pcrlong new value = %x ,
  37.           *((int *)where)  - (int)start_address
  38.           + symbol_table[relocation_info.r_symndx].n_value );
  39.       *(int *)where=  *((int *)where)  - (int)start_address
  40.     + symbol_table[relocation_info.r_symndx].n_value;
  41.       break;
  42.  
  43.     default:
  44.       fprintf(stdout, "%d: unsupported relocation type.",
  45.           relocation_info.r_type);
  46.       FEerror("The relocation type was unknown",0,0);
  47.     }
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54. #ifdef DEBUG
  55.  
  56. #define describe_sym describe_sym1
  57. describe_sym1(n)
  58. int n;
  59. {char *str;
  60.  char tem[9];
  61.  struct syment *sym;
  62.  sym= &symbol_table[n];
  63.  str= sym->n_zeroes == 0 ?
  64.    &my_string_table[sym->n_offset] :
  65.  (sym->n_name[SYMNMLEN -1] ?
  66.   /* MAKE IT NULL TERMINATED */
  67.   (strncpy(tem,sym->n_name,
  68.        SYMNMLEN),tem):
  69.   sym->n_name );
  70.  printf ("sym-index = %d table entry at %x",n,&symbol_table[n]);
  71.  printf("symbol is (%s):\nsymbol_table[n]._n._n_name %s\nsymbol_table[n]._n._n_n._n_zeroes %d\nsymbol_table[n]._n._n_n._n_offset %d\nsymbol_table[n]._n._n_nptr[0] %d\nsymbol_table[n]._n._n_nptr[n] %d\nsymbol_table[n].n_value %d\nsymbol_table[n].n_scnum %d
  72. \nsymbol_table[n].n_type %d\nsymbol_table[n].n_sclass %d\nsymbol_table[n].n_numaux %d", str,
  73.     symbol_table[n]._n._n_name,
  74.     symbol_table[n]._n._n_n._n_zeroes ,
  75.     symbol_table[n]._n._n_n._n_offset ,
  76.     symbol_table[n]._n._n_nptr[0] ,
  77.     symbol_table[n]._n._n_nptr[1] ,
  78.     symbol_table[n].n_value ,
  79.     symbol_table[n].n_scnum ,
  80.     symbol_table[n].n_type ,
  81.     symbol_table[n].n_sclass ,
  82.     symbol_table[n].n_numaux );
  83. }
  84.  
  85. #endif 
  86.